package com.zr.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JDBCUtil {
     private static final String DriverName="com.mysql.jdbc.Driver";
     private static final String DBUrl="jdbc:mysql://localhost:3306/work_management?useUnicode=true&characterEncoding=utf8";
     private static final String DBUname="root";
     private static final String DBPsw="123";
     public static Connection getDBConnection(){
    	 Connection con=null;
    	 try {
			Class.forName(DriverName);
			con=DriverManager.getConnection(DBUrl,DBUname,DBPsw);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	 return con;
     }
     public static void  closedConnection(Connection con){
		  if(con != null){
			  try {
				con.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		  }
	  }
}
